package com.lly.markdown

sealed class MarkdownItem
interface MarkdownListener {
    fun whenParseItem(item: MarkdownItem)
}

data class Heading(val level: Int, val content: List<Block>) : MarkdownItem()
data class Text(val content: List<Block>) : MarkdownItem()
data class MList(val items: List<MListItem>, val isOrder: Boolean) : MarkdownItem()
data class MCheckableList(val items: List<MCheckableListItem>) : MarkdownItem()
data class Error(val info: String) : MarkdownItem()
data class Code(val content: String) : MarkdownItem()
data class Table(val rows: List<Row>, val aligns: List<Int>) : MarkdownItem() {
    val maxColums by lazy { rows.maxOfOrNull { it.cells.size } ?: 0 }

    data class Row(val cells: List<List<Block>>) : MarkdownOtherItem()
    companion object {
        const val Left = 0
        const val Right = 1
        const val Center = 2
    }
}

sealed class MarkdownOtherItem()

data class MListItem(val indent: Int, val content: List<Block>, val children: List<MListItem>) :
    MarkdownOtherItem()

data class MCheckableListItem(
    val indent: Int,
    val content: List<Block>,
    val children: List<MCheckableListItem>,
    val isCheckable: Boolean
) :
    MarkdownOtherItem()

